package com.example.mapper;

import com.example.pojo.Goods;
import org.apache.ibatis.annotations.*;
import com.example.pojo.Student;

import com.example.pojo.Student;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface StudentMapper {
    List<Student> list(@Param("name") String name);

    // 查询学生基本信息
    @Select("SELECT * FROM student WHERE id = #{id}")
    Student findById(Integer id);

    // 查询学生发布的商品
    @Select("SELECT * FROM goods WHERE stu_id = #{stuId}")
    List<Goods> findPublishedGoods(Integer stuId);

    // 查询学生购买的商品
    @Select("SELECT g.* FROM goods g JOIN record r ON g.id = r.goods_id WHERE r.cus_id = #{cusId}")
    List<Goods> findPurchasedGoods(Integer cusId);

    // 更新学生信誉分
    @Update("UPDATE student SET credit_score = #{creditScore} WHERE id = #{id}")
    void updateCreditScore(@Param("id") Integer id, @Param("creditScore") Integer creditScore);

}